Repository navigation
fix(arithmetic): Improve arithmetic allowlists - #126742
Conversation
wmak
commented
Oct 7, 2026
- Instead of hardcoded allowlists, use the dataset definitions to determine what is and isn't allowed in arithmetic
- Closes BROWSE-807
- Instead of hardcoded allowlists, use the dataset definitions to determine what is and isn't allowed in arithmetic
| calculations, | ||
| [SimpleNamespace(**param) for param in data["references"]], | ||
| resolver.resolve_column, | ||
| resolver, |
There was a problem hiding this comment.
Dummy column fails non-span validation
Medium Severity
Formula save validation substitutes span.duration for every COLUMN parameter, then parse_formula and parse_arithmetic check that result against the dataset allowlist. Logs and metrics definitions do not include span.duration, so saving those formulas with column parameters now fails even when the real columns would be valid.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 366845f. Configure here.
| try: | ||
| _, _, _ = parse_arithmetic(final_equation, definitions=resolver.definitions) | ||
| except ArithmeticError as e: | ||
| raise InvalidSearchQuery(e) |
There was a problem hiding this comment.
Bug: The new parse_arithmetic validation breaks existing saved formulas using functions like trace_status_rate that are not marked with valid_arithmetic=True.
Severity: HIGH
Suggested Fix
Ensure all functions intended for use in formulas, including those from the old hardcoded allowlist like trace_status_rate, are marked with valid_arithmetic=True in their definitions. This will add them to the function_allowlist used by parse_arithmetic and prevent the new validation from incorrectly rejecting valid, existing formulas.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/sentry/search/eap/utils.py#L633-L636
Potential issue: The new validation step `parse_arithmetic(final_equation, ...)` in
`parse_formula` uses a function allowlist derived from definitions with
`valid_arithmetic=True`. However, some existing functions, such as `trace_status_rate`,
were not updated with this flag in the PR. As a result, existing saved formulas that use
these functions (e.g., via references) will now fail this new validation at query time,
raising an `InvalidSearchQuery` error. This is a regression, as these formulas were
previously valid and would execute successfully.
Did we get this right? 👍 / 👎 to inform future reviews.
|
Current version of PR was reviewed by /review-bugbot on Oct 8, 15:17 EDT. It flagged 0 findings. Bugbot on commit |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
There are 3 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e68222f. Configure here.

